import _ from "lodash";
import asleep from "@/common/asleep";
import { DEFAULT_AVATAR } from "@/common/avatar";

export type User = {
  id: number;
  username: string;
  password: string;
  avatar: string;
};

const USER: User = {
  id: 1,
  username: "admin",
  password: "noop::passwordhahaha",
  avatar: DEFAULT_AVATAR,
};

export const getUserByName = async (username: string): Promise<User | null> => {
  await asleep(200);

  if (username === "admin") {
    return _.cloneDeep(USER);
  }

  return null;
};

export const getUserById = async (id: number): Promise<User | null> => {
  await asleep(200);

  if (id === USER.id) {
    return _.cloneDeep(USER);
  }

  return null;
};
